package cn.witsky.cdrService.util;

import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.redis.core.StringRedisTemplate;
import cn.witsky.cdrService.SpringContextHolder;

public class RedisUtil {
	private static Logger logger = LoggerFactory.getLogger(RedisUtil.class);
	private static StringRedisTemplate redisTemplate;
	private static String cdrListKey="DC:CDR:INFO";
	
	static {
		redisTemplate=SpringContextHolder.getBean(StringRedisTemplate.class);
	}
	
	public static List<String> getCdrList() {
		try {
			return redisTemplate.opsForList().range(cdrListKey, 0, -1);
		}catch(Exception ex) {
			logger.error("读取话单信息出现异常:",ex);
			return null;
		}
	}
	public static void clearCdrListByLength(int length) {
		try {
			redisTemplate.opsForList().trim(cdrListKey, length,-1);
		}catch(Exception ex) {
			logger.error("读取话单信息出现异常:",ex);
		}
	}
}
